<template>
  <el-dialog v-model="visible" title="证书上传" width="500px">
    <el-upload
      v-if="FileInput"
      action="/system/license/upload"
      accept="cert"
      drag>
      <el-icon class="el-icon--upload"><upload-filled /></el-icon>
      <div class="el-upload__text">
        Drop file here or <em>click to upload</em>
      </div>
    </el-upload>

    <el-input
        v-else
        v-model="licenseText"
        :rows="5"
        type="textarea"
        placeholder="请将授权许可证信息复制到此处，然后点击下方的「激活」按钮进行激活。"/>

        <div class="el-upload__tip">
        切换
        <el-link v-if="FileInput" @click="FileInput = !FileInput">手动输入</el-link>
        <el-link v-else @click="FileInput = !FileInput">文件上传</el-link>
        许可证信息
        </div>
        <br></br>
        <el-button type="primary" @click="activeLicense">激活</el-button>
  </el-dialog>
</template>

<script lang="ts" setup>
import { ref, watch } from 'vue'

const visible = ref(false)
const FileInput = ref(true)

const licenseText = ref(null)

const props = defineProps({modelValue: Boolean})
const emit = defineEmits(['update:modelValue'])

watch(() => props.modelValue, (val) => {
   visible.value = val
})

watch(visible, (val) => {
    emit('update:modelValue', val)
})

const activeLicense = () => {

}
</script>

<style>
</style>
